import request from '@/utils/request'
import { AxiosPromise } from 'axios'
import { AdsBo, AdsVo } from '@/api/business/ads/types'

enum Api {
  list = '/ledger/list',
  delete = '/ledger/delete',
  batchDelete = '/ledger/batchDelete',
  add = '/ledger/add',
  edit = '/ledger/edit',
  detail = '/ledger/detail',
  settle = 'ledger/settle',
}

// 获取列表
export const ledgerList = (data: any): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}

// 删除
export const ledgerDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const ledgerBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 编辑、保存
export const ledgerSave = (data: AdsBo) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 获取设备详情
export const ledgerSettle = () => {
  return request({
    url: Api.settle,
    method: 'post',
  })
}
